﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class controls_BreakCumb : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        LoadBreakCumb();
    }

    private void LoadBreakCumb()
    {
        DataTable tblBreadCumb = createData().Tables[0];

        StringBuilder strB = new StringBuilder();
        strB.Append(@"<div class='btn-group btn-breadcrumb' id='bread-crumb'>");
        for (int i = 0; i < tblBreadCumb.Rows.Count; i++)
        {
            if (i == 0)
            {
                strB.Append(@"<a href='"+tblBreadCumb.Rows[i]["ID"].ToString()+"' class='btn btn-default'><i class='glyphicon glyphicon-home'></i></a>");
            }
            else
            {
                strB.Append(@"<a href='" + tblBreadCumb.Rows[i]["ID"].ToString() + "' class='btn btn-default'>" + tblBreadCumb.Rows[i]["NAME"].ToString() + "</a>");
            }

        }
        strB.Append("</div>");


        //            strB.Append(@"<div class='btn-group btn-breadcrumb' id='bread-crumb'>
        //                                    <a href='#' class='btn btn-default'><i class='glyphicon glyphicon-home'></i></a>
        //                                    <a href='#' class='btn btn-default'>Snippets</a>
        //                                    <a href='#' class='btn btn-default'>Breadcrumbs</a>
        //                                    <a href='#' class='btn btn-default'>Default</a>
        //                                </div>");
        ltrBreakCumb.Text = strB.ToString();
    }

    private DataSet createData()
    {
        DataSet ds = new DataSet();
        DataTable dt = new DataTable();
        dt.Columns.Add("ID");
        dt.Columns.Add("NAME");
        for (int i = 1; i < 5; i++)
        {
            DataRow dr = dt.NewRow();
            dr["ID"] = i.ToString();
            dr["NAME"] = i.ToString() + "NAME";
            dt.Rows.Add(dr);
        }
        ds.Tables.Add(dt);
        ds.AcceptChanges();

        return ds;
    }

}